let app = getApp()
Component({
    properties: {
         orderid:Number
      },
      data:{
        shengyu:0,
        groupNo: 0,
        list: [],
        groupCount: 0,
        avatarList: [],
        orderId: 0,
        groupStatus: 0,
        goodId: 0,
        defaultAvatar:'/static/image/noface.png'
      },
      pageLifetimes: {
        show: function () {
          var that=this
          wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'Group_getUserGroup',
                group_no:that.data.orderid,
                user_id:wx.getStorageSync('user_id')
              },
              success: function(res) {
                  var list=[ { 
                    endTime:res.data.data.group.end_time,
                    pic:res.data.data.group.pic,
                    title:res.data.data.group.goods_name,
                    price:res.data.data.group.activity_price,
                    goods_id:res.data.data.group.id,
                    id:res.data.data.group.id,
                    cate: "".concat(res.data.data.group.group_success, "人团").concat(res.data.data.group.group_virtual ? " · 已团" + res.data.data.group.group_virtual + "人" : ""),
                    link: {
                        type: "goods",
                        id: res.data.data.group.id,
                        activity: "group"
                    }
                  } ]
                  if(res.data.data.group_user.length>res.data.data.group.group_success){
                     that.setData({
                      groupFinish:true
                     })
                  }else{
                    var shengyu=res.data.data.group.group_success-res.data.data.group_user.length
                    that.setData({
                      groupFinish:false, 
                      shengyu:shengyu
                     })
                  }
                  that.setData({
                     orderId:res.data.data.group.order_id, 
                     groupStatus:res.data.data.group.group_order_status, 
                     goodId:res.data.data.group.id,
                     groupCount:res.data.data.group.group_success,
                     avatarList:res.data.data.group_user,
                     list:list,
                     groupCount:res.data.data.group_user
                  })
                 
              }
            })

          }
        },
    lifetimes: {
        attached: function () {
          wx.setNavigationBarTitle({
            title:'拼团详情'
          })
         }
      },
    methods: {
      goodsdetail:function(){
        wx.navigateTo({
          url: '/yb_shopv2/native/all/index?type=good_detail&goods_id='+this.data.goodId+'&activity=group',
        })
      }
    }
});
